package com.wyzz.hr.report.bo.impl;

import java.util.Comparator;

public class ExaminCellCompare implements Comparator {

	public ExaminCellCompare() {
	}

	public int compare(String o1, String o2) {
		String o1Str = o1.replace('|', ':').replace('|', ':').replace('|', ':');
		String o2Str = o2.replace('|', ':').replace('|', ':').replace('|', ':');
		int o1Index;
		int o2Index;
		try {
			o1Index = Integer.parseInt(o1Str.split(":")[1].trim());
			o2Index = Integer.parseInt(o2Str.split(":")[1].trim());
			if (o1Index - o2Index != 0 || o1Str.split(":").length <= 2
					|| o2Str.split(":").length <= 2)
				return o1Index - o2Index;
		} catch (NumberFormatException e) {
			return o1Str.split(":")[2].trim().compareTo(
					o2Str.split(":")[2].trim());
		}
		o1Index = Integer.parseInt(o1Str.split(":")[2].trim());
		o2Index = Integer.parseInt(o2Str.split(":")[2].trim());
		return o1Index - o2Index;
	}

	public int compare(Object x0, Object x1) {
		return compare((String) x0, (String) x1);
	}
}
